using Headspring.Training.Core.Model;

namespace Headspring.Training.Core.Services.Impl
{
	public class AuthenticationService : IAuthenticationService
	{
		private readonly ICryptographyService _cryptographyService;

		public AuthenticationService(ICryptographyService cryptographyService)
		{
			_cryptographyService = cryptographyService;
		}

		public bool PasswordMatches(Employee employee, string password)
		{
			string passwordHash = _cryptographyService.HashPassword(password,
			                                                        employee.PasswordSalt);
			return passwordHash.Equals(employee.PasswordHash);
		}

		public void SendPasswordEmail()
		{
			var notifier = new SmtpNotifier();
			notifier.Send("foo@bar.com", "You password is xxxxx");
		}
	}
}